﻿using CPPEI.Coolzon.UI.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace CPPEI.Coolzon.Designer.Views
{
    public partial class DesignView
    {
        /// <summary>
        /// 显示组件大小提示标签
        /// </summary>
        /// <param name="mousePointInCanvas"></param>
        /// <param name="parentCanvas"></param>
        /// <param name="partWidth"></param>
        /// <param name="partHeight"></param>
        private void ShowPartSizeLabel(Point mousePointInCanvas, Canvas parentCanvas, double partWidth, double partHeight)
        {
            this._ctlDesignLayoutPartSize.Visibility = System.Windows.Visibility.Visible;
            this._ctlDesignLayoutPartSize.Content = string.Format("{0},{1}", partWidth, partHeight);

            // 设置大小提示框的
            double canvasWidth = parentCanvas.ActualWidth;
            double canvasHeight = parentCanvas.ActualHeight;

            double labelWidth = this._ctlDesignLayoutPartSize.ActualWidth;
            double labelHeight = this._ctlDesignLayoutPartSize.ActualHeight;

            double left = mousePointInCanvas.X;
            double top = mousePointInCanvas.Y;
            if (mousePointInCanvas.X + labelWidth > canvasWidth)
            {
                left = canvasWidth - labelWidth;
            }

            if (mousePointInCanvas.Y + labelHeight > canvasHeight)
            {
                top = canvasHeight - labelHeight;
            }
            top = 0;
            Canvas.SetLeft(this._ctlDesignLayoutPartSize, left);
            Canvas.SetTop(this._ctlDesignLayoutPartSize, top);
        }

        /// <summary>
        /// 隐藏组件大小提示标签
        /// </summary>
        private void HidePartSizeLabel()
        {
            this._ctlDesignLayoutPartSize.Visibility = System.Windows.Visibility.Hidden;
        }
    }
}
